package questionLibrary;

public class OrganInfo {

	private int organParameters[][];

	public OrganInfo(){          
		organParameters = new int[SomeConstants.COUNT_OF_ORGANS][SomeConstants.COUNT_OF_PARAMS];
	}

	public boolean wrongArguments(int organ, int param) {
		if (organ >= SomeConstants.COUNT_OF_ORGANS || organ < 0)
			return true;
		if (param >= SomeConstants.COUNT_OF_PARAMS || param < 0)
			return true;
		return false; //all is OK
	}

	public void setParameter(int organ, int param, int value){
		if (this.wrongArguments(organ,param)) 
			throw new IllegalArgumentException("It was specified wrong organ or parameter!");    
		organParameters[organ][param] = value;
	}

	public int getParameter(int organ, int param){    
		if (this.wrongArguments(organ,param))
			throw new IllegalArgumentException("It was specified wrong organ or parameter!");
		return organParameters[organ][param];
	}

	public void addParameters(OrganInfo values){
		for (int currentOrgan = 0; currentOrgan < SomeConstants.COUNT_OF_ORGANS; currentOrgan++)
			for (int currentParam = 0; currentParam < SomeConstants.COUNT_OF_PARAMS; currentParam++)
				organParameters[currentOrgan][currentParam] += values.getParameter(currentOrgan, currentParam);
	}

}
